//
//  QDMPSectionHeaderView.m
//  QDMetroClient
//
//  Created by YueWen on 2019/2/14.
//  Copyright © 2019 YueWen. All rights reserved.
//

#import "QDMPSectionHeaderView.h"

@implementation QDMPSectionHeaderView

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self buildViews];
    }
    return self;
}


- (instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithReuseIdentifier:reuseIdentifier]) {
        [self buildViews];
    }
    return self;
}


- (void)buildViews {
    
    //如果已经初始化完毕了，就不需要
    if (_titleLabel) { return; }
    self.contentView.backgroundColor = /*UIColor.whiteColor*/QDSMainPageBottomColor;
    
    self.titleLabel = ({
        
        UILabel *label = [UILabel new];
        label.backgroundColor = /*[UIColor whiteColor]*/QDSMainPageBottomColor;
        label.text = @"地铁资讯";
        label.font = RITLSemiboldFont(22);
        label.textColor = QDSColorDefaultBlack;
        
        label;
    });
    
    self.moreButton = ({
        
        UIButton *view = [UIButton new];
        view.adjustsImageWhenHighlighted = false;
        view.backgroundColor = /*[UIColor whiteColor]*/QDSMainPageBottomColor;
        view.adjustsImageWhenHighlighted = false;
        view.adjustsImageWhenDisabled = false;
        view.titleLabel.font = RITLRegularFont(12);
        
        view.titleEdgeInsets = UIEdgeInsetsMake(0, -16, 0, 16);
        view.imageEdgeInsets = UIEdgeInsetsMake(0.5, 48, 0, -48);
        
        [view setTitle:@"查看更多" forState:UIControlStateNormal];
        [view setTitleColor:QDSColorDefaultGray forState:UIControlStateNormal];
        [view setImage:@"mp_sh_header_arrow_right".ritl_image forState:UIControlStateNormal];
        
        view;
    });
    
    [self.contentView addSubview:self.titleLabel];
    [self.contentView addSubview:self.moreButton];
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(20);
        make.top.offset(23);
        make.height.mas_equalTo(30);
    }];
    
    [self.moreButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.inset(16);
        make.top.offset(29);
        make.height.mas_equalTo(17);
    }];
}

@end
